<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>注册成功</title>
    <style type="text/css" media="screen">
         *{margin:0; padding: 0;}
        body{background:url(img/4.jpg) no-repeat center center fixed; background-size: cover; font-family: 微软雅黑;}
        div{width: 500px;height: 200px;margin:80px auto; text-align: center;background-color: rgba(205,205,205,.4); border-radius: 50px; line-height: 200px;font-size: 20px;}
    </style>
</head>
<body>
   <?php
      error_reporting(0); 
      $conn=mysql_connect("localhost","root","") or die("连接服务器失败".mysql_error());
      $db_name="login" or die("连接数据库失败".mysql_error());
      mysql_select_db($db_name,$conn);
      mysql_query("set names'utf8'");

      $username=$_POST["user"];
      $userpwd=$_POST["pwd"];

      if($username==""||$userpwd==""){
      echo"<script type='text/javascript'>     alert('用户名或密码不能为空');
          location='register.html';</script>";}else{

        $sql="select Uname from user where Uname='$username'";
            $result=mysql_query($sql,$conn);
            $row=mysql_num_rows($result);
       if ($row>0) {
           echo"<script type='text/javascript'>alert('此用户已经存在，请重新注册！');location='register.html';</script>";
       }else{
             $sql_b="insert into user values('$username','$userpwd')";
             $result_b=mysql_query($sql_b,$conn);
        echo "<div>恭喜您注册成功！5S后跳转到登录页面！</div>";
       print'<meta http-equiv="refresh" content="5;url=login.html">';
    }

}
          mysql_close($conn); 
        ?>

</body>
</html>